package com.woniuxy.commons.factory;

import com.woniuxy.commons.dto.CourseDto;
import com.woniuxy.commons.entity.*;
import com.woniuxy.commons.service.RemoteCourseService;
import feign.hystrix.FallbackFactory;
import org.springframework.stereotype.Component;

import java.util.Arrays;
import java.util.List;

/**
 * @author 吴毛伟
 * @date:2020/7/9 10:24
 * @description:
 */
@Component
public class RemoteCourseServiceFactory implements FallbackFactory<RemoteCourseService> {
    @Override
    public RemoteCourseService create(Throwable cause) {
        return new RemoteCourseService() {
            @Override
            public ResponseEntity<PageBean<CourseDto>> queryCoursesByCondition(CourseDto condition) {
                return (ResponseEntity<PageBean<CourseDto>>) Arrays.asList(new Course().setCname("课程模块掉了，赶紧联系工作人员!"));
            }

            @Override
            public ResponseEntity<Course> findCourseByCid(int cid) {
                return (ResponseEntity<Course>) Arrays.asList(new Course().setCname("课程模块掉了，赶紧联系工作人员!"));
            }

            @Override
            public ResponseEntity findCoursewareByCwid(Courseware courseware) {
                return new ResponseEntity().setMessage("出错啦");
            }

            @Override
            public ResponseEntity<List<CourseCategory>> findAllCategories() {
                return (ResponseEntity<List<CourseCategory>>) Arrays.asList(new CourseCategory().setCategoryName("出问题了"));
            }

            @Override
            public ResponseEntity<List<CourseChapter>> findChapterByCid(int cid) {
                return (ResponseEntity<List<CourseChapter>>) Arrays.asList(new CourseChapter().setCpname("出错啦"));
            }

            @Override
            public ResponseEntity<List<Courseware>> findCoursewaresByCpid(int cpid) {
                return (ResponseEntity<List<Courseware>>) Arrays.asList(new Courseware().setCwname("出错啦"));
            }

            @Override
            public ResponseEntity<List<Teacher>> findAllTeachers() {
                return (ResponseEntity<List<Teacher>>) Arrays.asList(new Teacher().setTname("出错啦"));
            }
        };
    }
}
